pub fn convert_base(num_str: &str, to_base: u32) -> String {

    let parts: Vec<&str> = num_str.split(|c| c == '(' || c == ')').collect();

    let number1: u32 = parts[0].trim().parse().expect("Not a valid number");
    let number2: u32 = parts[1].trim().parse().expect("Not a valid number");

    let mut count = 0;
    let mut base_power = 1; 
    let mut temp_num = number1;


    while temp_num > 0 {
        let digit = temp_num % 10; 
        count += digit * base_power; 
        base_power *= number2; 
        temp_num /= 10;
    }
    if count == 0 {
        return "0".to_string();
    }
    let mut memory = Vec::new();
    while count > 0 {
        let remainder = count % to_base; 
        memory.push(remainder); 
        count /= to_base; 
    }


    memory.reverse();

    let result: String = memory.iter()
        .map(|&digit| {
            if digit < 10 {
                (digit as u8 + b'0') as char 
            } else {
                (digit as u8 - 10 + b'a') as char 
            }
        })
        .collect();

    result
}